package c.e.b.h.e.k;

import android.content.Context;
import android.util.Log;
import c.e.a.b.g.a0;
import c.e.a.b.g.g;
import c.e.b.c;
import c.e.b.h.e.s.d;
import c.e.b.h.e.s.e;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

/* compiled from: CrashlyticsCore */
public class f0 {
    public final Context a;
    public final c b;
    public final l0 c;
    public final long d = System.currentTimeMillis();
    public h0 e;
    public h0 f;
    public t g;
    public final q0 h;
    public final c.e.b.h.e.j.a i;
    public final c.e.b.h.e.i.a j;
    public ExecutorService k;
    public h l;
    public c.e.b.h.e.a m;

    /* compiled from: CrashlyticsCore */
    public class a implements Runnable {
        public final /* synthetic */ e a;

        public a(e eVar) {
            this.a = eVar;
        }

        public void run() {
            f0.a(f0.this, this.a);
        }
    }

    /* compiled from: CrashlyticsCore */
    public class b implements Callable<Boolean> {
        public Object call() throws Exception {
            c.e.b.h.e.b bVar = c.e.b.h.e.b.a;
            try {
                boolean delete = f0.this.e.b().delete();
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("Initialization marker file removed: ");
                stringBuilder.append(delete);
                bVar.b(stringBuilder.toString());
                bVar = Boolean.valueOf(delete);
                return bVar;
            } catch (Exception e) {
                if (bVar.a(6)) {
                    Log.e("FirebaseCrashlytics", "Problem encountered deleting Crashlytics initialization marker.", e);
                }
                return Boolean.FALSE;
            }
        }
    }

    public f0(c cVar, q0 q0Var, c.e.b.h.e.a aVar, l0 l0Var, c.e.b.h.e.j.a aVar2, c.e.b.h.e.i.a aVar3, ExecutorService executorService) {
        this.b = cVar;
        this.c = l0Var;
        cVar.a();
        this.a = cVar.a;
        this.h = q0Var;
        this.m = aVar;
        this.i = aVar2;
        this.j = aVar3;
        this.k = executorService;
        this.l = new h(executorService);
    }

    public static g a(f0 f0Var, e eVar) {
        g v;
        String str = "Collection of crash reports disabled in Crashlytics settings.";
        c.e.b.h.e.b bVar = c.e.b.h.e.b.a;
        f0Var.l.a();
        f0Var.e.a();
        bVar.b("Initialization marker file created.");
        t tVar = f0Var.g;
        h hVar = tVar.e;
        hVar.b(new i(hVar, new o(tVar)));
        try {
            f0Var.i.a(new d0(f0Var));
            d dVar = (d) eVar;
            c.e.b.h.e.s.i.e c = dVar.c();
            if (c.b().a) {
                if (!f0Var.g.h(c.a().a)) {
                    bVar.b("Could not finalize previous sessions.");
                }
                v = f0Var.g.v(1.0f, dVar.a());
            } else {
                bVar.b(str);
                RuntimeException runtimeException = new RuntimeException(str);
                v = new a0();
                v.m(runtimeException);
            }
        } catch (Exception e) {
            str = "Crashlytics encountered a problem during asynchronous initialization.";
            if (bVar.a(6)) {
                Log.e("FirebaseCrashlytics", str, e);
            }
            v = new a0();
            v.m(e);
        } catch (Throwable th) {
            f0Var.c();
        }
        f0Var.c();
        return v;
    }

    public final void b(e eVar) {
        String str = "FirebaseCrashlytics";
        c.e.b.h.e.b bVar = c.e.b.h.e.b.a;
        Future submit = this.k.submit(new a(eVar));
        bVar.b("Crashlytics detected incomplete initialization on previous app launch. Will initialize synchronously.");
        try {
            submit.get(4, TimeUnit.SECONDS);
        } catch (InterruptedException e) {
            if (bVar.a(6)) {
                Log.e(str, "Crashlytics was interrupted during initialization.", e);
            }
        } catch (ExecutionException e2) {
            if (bVar.a(6)) {
                Log.e(str, "Problem encountered during Crashlytics initialization.", e2);
            }
        } catch (TimeoutException e3) {
            if (bVar.a(6)) {
                Log.e(str, "Crashlytics timed out during initialization.", e3);
            }
        }
    }

    public void c() {
        this.l.b(new b());
    }
}
